package cn.iocoder.yudao.module.common.dal.mysql.textbookversion;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.common.dal.dataobject.textbookversion.TextbookVersionDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.common.controller.admin.textbookversion.vo.*;

/**
 * 教材版本 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface TextbookVersionMapper extends BaseMapperX<TextbookVersionDO> {

    default PageResult<TextbookVersionDO> selectPage(TextbookVersionPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<TextbookVersionDO>()
                .likeIfPresent(TextbookVersionDO::getVersionName, reqVO.getVersionName())
                .eqIfPresent(TextbookVersionDO::getSubjectId, reqVO.getSubjectId())
                .eqIfPresent(TextbookVersionDO::getGradeId, reqVO.getGradeId())
                .eqIfPresent(TextbookVersionDO::getCoverUrl, reqVO.getCoverUrl())
                .likeIfPresent(TextbookVersionDO::getCreatorName, reqVO.getCreatorName())
                .betweenIfPresent(TextbookVersionDO::getCreateTime, reqVO.getCreateTime())
                .likeIfPresent(TextbookVersionDO::getUpdaterName, reqVO.getUpdaterName())
                .eqIfPresent(TextbookVersionDO::getVersion, reqVO.getVersion())
                .orderByDesc(TextbookVersionDO::getId));
    }

}